<?php
require_once (APPLICATION_DIR."/application/model/Node.php");
class Node extends DataObjects_Node
{	
	function getNodeInfo($node_id)
	{
		$this->selectAdd();
		$this->selectAdd("node_title,node_content");
		$this->whereAdd();
		$this->whereAdd("node_id = $node_id");
		$this->find();
		return $this;
	}
	
	function updateNode($node_id,$node_title,$node_content,$node_cat_id = 0)
	{
		$this->node_id		= $node_id;
		$this->node_title 	= $node_title;
		$this->node_content = $node_content;
		$this->node_cat_id	= $node_cat_id;
		$this->update();
	}
	
	function getNextNodeID()
	{
		$node	= new Node();
		$node->insert();
		
		$this->selectAdd();
		$this->selectAdd("node_id");
		$this->orderBy("node_id DESC");
		$this->find();
		$this->fetch();
		$result = $this->node_id;
		return $result;
	}
	
	function preparePage($node_id)
	{
	    $smarty = DRX::load('smarty');
	    
	    $nodeInfo	= $this->getNodeInfo($node_id);
		if ($nodeInfo->fetch())
		{
            $title		= $nodeInfo->node_title;
            $content	= $nodeInfo->node_content;
            $smarty->assign("title",$title);
            $smarty->assign("content",$content);
            return true;
		}
        else 
        {
            return false;
        }
	}
}
?>